<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>忘记密码</title>
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta name="msapplication-tap-highlight" content="no">
		<link rel="stylesheet" href="css/common.css" />
		<link rel="stylesheet" href="css/register.css" />
		<link rel="stylesheet" href="layer_mobile/need/layer.css" />
		<script type="text/javascript" src="js/font-size.js"></script>
		<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="layer_mobile/layer.js"></script>
		<script type="text/javascript" src="js/register.js"></script>
		<script type="text/javascript" src="js/global_variable.js" ></script>
	</head>
	<body style="background:#fff;">
		<div class="container">
			<header>
				<div class="title_top">
					<a href="login.html" class="title_top_first">
						<img src="img/back.png" class="hea_img" />
					</a>
					<span class="title_top_center">忘记密码</span>
				</div>
			</header>
			<div class="main">
				<div class="main_bak_login">
					<div class="photo_img">
					<img src='img/login/dribs.png' class="photo_img_bg">
						<p class="photo_img_p">
							<img src="img/login/palm.png" />
						</p>
					</div>
					<div class="main_infor">
						<p style="color:#b61c25; text-align:center;">请输入注册时的手机号</p>
						<ul class="main_infor_name">
							<li class="name_li name_input">
								<input type="text" placeholder="手机号" id="uname" />
							</li>
							<li class="name_li name_input">
								<input type="text" placeholder="图片验证码" class="yzm" id="img_codema" />
								<img class="img_yanzhengma" id="img_yanzhengma_id" /> 
							</li>
						</ul>
					</div>
					<!--输入手机号验证码结束-->
					<div class="main_btn">
						<button type="button" class="main_btn_a mian_btn_login" disabled="">
							下一步
						</button>
					</div>
				</div>
			</div>
		</div>
	</body>	
	<script>
		$(function() {
			example();
			var imagecode = localStorage.getItem('imagecode');
			$("#img_yanzhengma_id").attr("src", domain_name_url+"/user?method=getImgCode&key=" + imageCodeKey);
			// console.log(imagecode)
			/*图片验证码*/
			$(".img_yanzhengma").click(function() {
				example();
				$("#img_yanzhengma_id").attr("src", domain_name_url + "/user?method=getImgCode&key=" + imageCodeKey);
			});
			//	手机号码格式验证
			$("#uname").blur(function() {
				var reg = /^1[3|4|5|7|9|6|8][0-9]\d{4,8}$/;
				var uname = $('#uname').val().replace(/\s+/g, "");
				var name = document.getElementById("uname").value;
				if(name==''){
					layer.open({
						content: '请输入手机号',
						skin: 'msg',
						time: 2
					});
				}else if(!reg.test(uname)) {
					layer.open({
						content: '手机号格式不正确',
						skin: 'msg',
						time: 2
					});
				} else {
					$('.mian_btn_login').removeAttr('disabled');
					$('.mian_btn_login').css({'background':'#b61c25','color':'#fff'});
				}
				
			});
			
			//点击下一步
			$(document).on("click", ".mian_btn_login", function() {
				var name = document.getElementById("uname").value;
				localStorage.setItem('name',document.getElementById("uname").value);
				var timg = $("#img_codema").val(); 
				if(name==''){
					layer.open({
						content: '请输入手机号',
						skin: 'msg',
						time: 2
					});
					return false;
				}
				if(timg==''){
					layer.open({
						content: '请输入图片验证码',
						skin: 'msg',
						time: 2
					});
					return false;
				}
				$.ajax({
					url: domain_name_url + "/user",
					type: "GET",
					dataType: "jsonp", //指定服务器返回的数据类型
					data: {
						method: 'getCheckCodeAndPhone',
						phone: name,
						key: imagecode,
						imgCode: timg,
						url_type:'user'
					},
					success: function(data) {
						if(data.success==3){
							window.location.href='after_forget_password.html';
						}else if(data.success==1){
							layer.open({
								content: '用户不存在',
								skin: 'msg',
								time: 2
							});
							$('.mian_btn_login').attr("disabled",true);
							$('.mian_btn_login').css({'background':'#ebebeb','color':'#b3b3b3'});
						}else if(data.success==4){
							layer.open({
								content: data.errorMessage,
								skin: 'msg',
								time: 2
							});
							$('.mian_btn_login').attr("disabled",true);
							$('.mian_btn_login').css({'background':'#ebebeb','color':'#b3b3b3'});
						}
					}
				})	
			});

		})
	</script>
</html>